﻿using EMS20.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace EMS20.UI
{
    /// <summary>
    /// 退出登录
    /// </summary>
    public class LogOut : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            //清空Session
            context.Session.Abandon();

            //清空Cookies
            HttpCookie cookie = context.Request.Cookies[Kits.CookieId];

            //判断是否有7天免登录
            if (cookie != null)
            {
                cookie.Expires = DateTime.Now.AddYears(-1);
                context.Response.Cookies.Add(cookie);
            }


            //返回登录页面
            context.Response.Write("<script>alert('退出成功');window.location='/Login/Login.html'</script>");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}